<template>
	<AdminLayout activeKey="activity-audit" :breadcrumbs="['首页','活动审核']" tabTitle="活动审核">
		<view class="page">
			<view class="section-header">
				<text class="section-title">活动审核</text>
				<text class="section-desc">审核校园圈子中的活动内容，管理活动发布</text>
			</view>

			<!-- 筛选工具栏 -->
			<view class="filter-toolbar">
				<input 
					class="search-input" 
					v-model="filters.keyword" 
					placeholder="搜索活动标题或内容" 
					@input="onSearchInput"
					@confirm="onSearchConfirm"
				/>
				<picker mode="selector" :range="categoryOptions" @change="onCategoryChange">
					<view class="picker-btn">类型：{{ filters.category || '全部' }}</view>
				</picker>
				<picker mode="selector" :range="statusOptions" @change="onStatusChange">
					<view class="picker-btn">状态：{{ filters.status || '全部' }}</view>
				</picker>
				<button class="filter-btn" @click="loadActivities">刷新</button>
				<button class="create-btn" @click="createOfficialActivity">创建官方活动</button>
			</view>
			
			<scroll-view scroll-y class="content-list">
				<view v-for="activity in activityList" :key="activity._id" class="content-item" 
				      :class="{
				        pending: activity.status === 'pending_review',
				        approved: activity.status === 'reviewed_approved',
				        rejected: activity.status === 'reviewed_rejected'
				      }">
					<view class="content-header">
					<view class="content-meta">
							<text class="content-category">{{ activity.category || '其他' }}</text>
							<text class="content-status" :class="activity.status">{{ getStatusText(activity.status) }}</text>
							<text class="attendee-info">人数：{{ activity.attendee_count }}/{{ activity.max_attendees }}</text>
					</view>
						<text class="publish-time">{{ formatTime(activity.activity_time) }}</text>
					</view>
					
					<view class="content-main">
						<text class="content-title">{{ activity.title }}</text>
						<text class="content-text">{{ filterRichText(activity.content) }}</text>
						<view class="activity-info">
							<text>地点：{{ activity.location }}</text>
						<text>发布者：{{ activity.user_info?.nickname || activity.publisher?.nickname || activity.publisher_name || activity.user_name || '未知用户' }}</text>
					</view>
					</view>

					<view class="content-actions">
						<!-- 审核按钮组 -->
						<view v-if="getAvailableAuditActions(activity).length > 0" class="audit-actions">
							<button 
								v-for="action in getAvailableAuditActions(activity)" 
								:key="action.key"
								class="audit-btn"
								:class="action.type"
								@click="auditActivity(activity, action.key)"
							>
								{{ action.text }}
							</button>
						</view>
						
						<button class="action-btn detail-btn" @click="viewActivityDetail(activity)">
							<text class="iconfont icon-chakan"></text>
							<text>查看详情</text>
						</button>
						<button class="action-btn edit-btn" @click="editActivity(activity)">
							<text class="iconfont icon-edit"></text>
							<text>编辑</text>
						</button>
						<button class="action-btn hide-btn" @click="hideActivity(activity)">
							<text class="iconfont icon-a-eyeclose-fill"></text>
							<text>隐藏</text>
						</button>
						<button class="action-btn down-btn" @click="takeDownActivity(activity)">
							<text class="iconfont icon-jinzhi"></text>
							<text>下架</text>
						</button>
						<button class="action-btn delete-btn" @click="deleteActivity(activity)">
							<text class="iconfont icon-shanchu"></text>
							<text>删除</text>
						</button>
					</view>
				</view>
			</scroll-view>
		</view>

		<!-- 创建活动弹窗 -->
		<view v-if="showCreateModal" class="modal-overlay" @click="closeCreateModal">
			<view class="modal-content" @click.stop>
				<view class="modal-header">
					<text class="modal-title">创建官方活动</text>
					<text class="modal-close" @click="closeCreateModal">×</text>
				</view>
				
				<scroll-view scroll-y class="modal-body">
					<view class="form-group">
						<text class="form-label">活动标题</text>
						<input class="form-input" v-model="newActivity.title" placeholder="请输入活动标题" />
					</view>
					
					<view class="form-group">
						<text class="form-label">活动类型</text>
						<picker mode="selector" :range="categoryOptions.slice(1)" @change="onNewActivityCategoryChange" class="picker-wrapper">
							<view class="form-picker">{{ newActivity.category || '请选择活动类型' }}</view>
						</picker>
					</view>
					
					<view class="form-group">
						<text class="form-label">活动封面</text>
						<view class="cover-upload-container">
							<view v-if="newActivity.cover_image" class="cover-preview">
								<image :src="newActivity.cover_image" class="cover-image" mode="aspectFill" />
								<view class="cover-actions">
									<button class="cover-btn change-btn" @click="chooseCoverImage">更换</button>
									<button class="cover-btn remove-btn" @click="removeCoverImage">删除</button>
								</view>
							</view>
							<view v-else class="cover-upload" @click="chooseCoverImage">
								<text class="iconfont icon-tupian upload-icon"></text>
								<text class="upload-text">点击上传活动封面</text>
								<text class="upload-tip">建议尺寸：750x400px，支持jpg/png格式</text>
							</view>
						</view>
					</view>
					
					<view class="form-group">
						<text class="form-label">活动作者</text>
						<input class="form-input" v-model="newActivity.author_name" placeholder="请输入活动作者名称" />
					</view>
					
					<view class="form-group">
						<text class="form-label">活动时间</text>
						<view class="datetime-picker-group">
							<picker mode="date" :value="getDateValue(newActivity.activity_time)" @change="onActivityDateChange" class="picker-wrapper date-picker">
								<view class="form-picker">{{ getDateValue(newActivity.activity_time) || '选择日期' }}</view>
							</picker>
							<picker mode="time" :value="getTimeValue(newActivity.activity_time)" @change="onActivityTimeChange" class="picker-wrapper time-picker">
								<view class="form-picker">{{ getTimeValue(newActivity.activity_time) || '选择时间' }}</view>
							</picker>
						</view>
					</view>
					
					<view class="form-group">
						<text class="form-label">活动地点</text>
						<input class="form-input" v-model="newActivity.location" placeholder="请输入活动地点" />
					</view>
					
					<view class="form-group">
						<text class="form-label">最大参与人数</text>
						<input class="form-input" type="number" v-model="newActivity.max_attendees" placeholder="请输入最大参与人数" />
					</view>
					
					<view class="form-group">
						<text class="form-label">活动描述</text>
						<textarea class="form-textarea" v-model="newActivity.content" placeholder="请输入活动描述" />
					</view>
				</scroll-view>
				
				<view class="modal-footer">
					<button class="modal-btn cancel-btn" @click="closeCreateModal">取消</button>
					<button class="modal-btn confirm-btn" @click="createActivity">创建活动</button>
				</view>
			</view>
		</view>

		<!-- 活动详情弹窗 -->
		<view v-if="showDetailModal" class="modal-overlay" @click="closeDetailModal">
			<view class="detail-modal" @click.stop>
				<view class="modal-header">
					<text class="modal-title">活动详情</text>
					<text class="modal-close" @click="closeDetailModal">×</text>
				</view>
				
				<scroll-view scroll-y class="modal-body">
					<view v-if="currentDetailActivity" class="detail-content">
						<view class="detail-section">
							<text class="detail-label">活动标题</text>
							<text class="detail-value">{{ currentDetailActivity.title }}</text>
						</view>
						
						<view class="detail-section">
							<text class="detail-label">活动类型</text>
							<text class="detail-value">{{ currentDetailActivity.category || '其他' }}</text>
						</view>
						
						<view class="detail-section">
							<text class="detail-label">活动时间</text>
							<text class="detail-value">{{ formatTime(currentDetailActivity.activity_time) }}</text>
						</view>
						
						<view class="detail-section">
							<text class="detail-label">活动地点</text>
							<text class="detail-value">{{ currentDetailActivity.location }}</text>
						</view>
						
						<view class="detail-section">
							<text class="detail-label">参与人数</text>
							<text class="detail-value">{{ currentDetailActivity.attendee_count }}/{{ currentDetailActivity.max_attendees }}</text>
						</view>
						
						<view class="detail-section">
							<text class="detail-label">活动状态</text>
							<text class="detail-value status" :class="currentDetailActivity.status">{{ getStatusText(currentDetailActivity.status) }}</text>
						</view>
						
						<view class="detail-section">
							<text class="detail-label">发布者</text>
							<text class="detail-value">{{ currentDetailActivity.user_info?.nickname || currentDetailActivity.publisher?.nickname || currentDetailActivity.publisher_name || currentDetailActivity.user_name || '未知用户' }}</text>
						</view>
						
						<view class="detail-section full-width">
							<text class="detail-label">活动描述</text>
							<scroll-view scroll-y class="detail-description-container">
								<text class="detail-description">{{ currentDetailActivity.content || '暂无描述' }}</text>
							</scroll-view>
						</view>
					</view>
				</scroll-view>
				
				<view class="modal-footer">
					<button class="modal-btn close-btn" @click="closeDetailModal">关闭</button>
				</view>
			</view>
		</view>

		<!-- 编辑活动弹窗 -->
		<view v-if="showEditModal" class="modal-overlay" @click="closeEditModal">
			<view class="modal-content" @click.stop>
				<view class="modal-header">
					<text class="modal-title">编辑活动</text>
					<text class="modal-close" @click="closeEditModal">×</text>
				</view>
				
				<scroll-view scroll-y class="modal-body">
					<view class="form-group">
						<text class="form-label">活动标题 *</text>
						<input class="form-input" v-model="editForm.title" placeholder="请输入活动标题" />
					</view>
					
					<view class="form-group">
						<text class="form-label">活动类型 *</text>
						<picker mode="selector" :range="categoryOptions.slice(1)" @change="onEditActivityCategoryChange" class="picker-wrapper">
							<view class="form-picker">{{ editForm.category || '请选择活动类型' }}</view>
						</picker>
					</view>
					
					<view class="form-group">
						<text class="form-label">活动封面</text>
						<view class="cover-upload-container">
							<view v-if="editForm.cover_image" class="cover-preview">
								<image :src="editForm.cover_image" class="cover-image" mode="aspectFill" />
								<view class="cover-actions">
									<button class="cover-btn change-btn" @click="chooseEditCoverImage">更换</button>
									<button class="cover-btn remove-btn" @click="removeEditCoverImage">删除</button>
								</view>
							</view>
							<view v-else class="cover-upload" @click="chooseEditCoverImage">
								<text class="iconfont icon-tupian upload-icon"></text>
								<text class="upload-text">点击上传活动封面</text>
								<text class="upload-tip">建议尺寸：750x400px，支持jpg/png格式</text>
							</view>
						</view>
					</view>
					
					<view class="form-group">
						<text class="form-label">活动作者 *</text>
						<input class="form-input" v-model="editForm.author_name" placeholder="请输入活动作者名称" />
					</view>
					
					<view class="form-group">
						<text class="form-label">活动时间 *</text>
						<view class="datetime-picker-group">
							<picker mode="date" :value="getDateValue(editForm.activity_time)" @change="onEditActivityDateChange" class="picker-wrapper date-picker">
								<view class="form-picker">{{ getDateValue(editForm.activity_time) || '选择日期' }}</view>
							</picker>
							<picker mode="time" :value="getTimeValue(editForm.activity_time)" @change="onEditActivityTimeChange" class="picker-wrapper time-picker">
								<view class="form-picker">{{ getTimeValue(editForm.activity_time) || '选择时间' }}</view>
							</picker>
						</view>
					</view>
					
					<view class="form-group">
						<text class="form-label">活动地点 *</text>
						<input class="form-input" v-model="editForm.location" placeholder="请输入活动地点" />
					</view>
					
					<view class="form-group">
						<text class="form-label">最大参与人数 *</text>
						<input class="form-input" type="number" v-model="editForm.max_attendees" placeholder="请输入最大参与人数" />
					</view>
					
					<view class="form-group">
						<text class="form-label">活动描述 *</text>
						<textarea class="form-textarea" v-model="editForm.content" placeholder="请输入活动描述" />
					</view>
				</scroll-view>
				
				<view class="modal-footer">
					<button class="modal-btn cancel-btn" @click="closeEditModal">取消</button>
					<button class="modal-btn confirm-btn" @click="saveActivityEdit">保存</button>
				</view>
			</view>
		</view>
	</AdminLayout>
</template>

<script>
import AdminLayout from '@/components/AdminLayout.vue'

export default {
	components: { AdminLayout },
	data() {
		return {
			activityList: [],
			allActivityList: [], // 存储所有活动数据，用于本地搜索
			filters: {
				keyword: '',
				category: '',
				status: ''
			},
			categoryOptions: ['全部', '官方', '社团', '学术', '体育', '娱乐', '其他'],
			statusOptions: ['全部', '待审核', '已发布', '已审核通过', '已审核拒绝', '已隐藏', '已删除'],
			searchTimer: null, // 搜索防抖定时器
			showCreateModal: false, // 控制创建活动弹窗显示
			showDetailModal: false, // 控制详情弹窗显示
			showEditModal: false, // 控制编辑活动弹窗显示
			currentDetailActivity: null, // 当前查看详情的活动
			currentEditActivity: null, // 当前编辑的活动
			newActivity: {
				title: '',
				category: '',
				activity_time: '',
				location: '',
				max_attendees: '',
				content: '',
				cover_image: '', // 活动封面图片
				author_name: '官方', // 活动作者
				author_avatar: '', // 作者头像
				// 临时存储日期和时间
				selectedDate: '',
				selectedTime: ''
			},
			editForm: {
				title: '',
				category: '',
				activity_time: '',
				location: '',
				max_attendees: '',
				content: '',
				cover_image: '', // 活动封面图片
				author_name: '官方', // 活动作者
				author_avatar: '', // 作者头像
				// 临时存储日期和时间
				selectedDate: '',
				selectedTime: ''
			}
		}
	},

	mounted() {
		this.loadActivities()
	},

	methods: {
		// 时间格式化
		formatTime(v) {
			if (!v) return '--'
			const d = new Date(v)
			const p = n => String(n).padStart(2, '0')
			return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
		},
		
		// 获取日期值 (YYYY-MM-DD格式)
		getDateValue(timestamp) {
			if (!timestamp) return ''
			const d = new Date(timestamp)
			const p = n => String(n).padStart(2, '0')
			return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`
		},
		
		// 获取时间值 (HH:MM格式)
		getTimeValue(timestamp) {
			if (!timestamp) return ''
			const d = new Date(timestamp)
			const p = n => String(n).padStart(2, '0')
			return `${p(d.getHours())}:${p(d.getMinutes())}`
		},

		// 富文本过滤，只保留纯文本
		filterRichText(content) {
			if (!content) return ''
			
			// 去除HTML标签
			let text = content.replace(/<[^>]*>/g, '')
			
			// 去除常见的富文本标记
			text = text.replace(/\*\*(.*?)\*\*/g, '$1') // 粗体 **text**
			text = text.replace(/\*(.*?)\*/g, '$1') // 斜体 *text*
			text = text.replace(/~~(.*?)~~/g, '$1') // 删除线 ~~text~~
			text = text.replace(/`(.*?)`/g, '$1') // 行内代码 `code`
			text = text.replace(/```[\s\S]*?```/g, '') // 代码块
			text = text.replace(/!\[.*?\]\(.*?\)/g, '') // 图片 ![alt](url)
			text = text.replace(/\[([^\]]+)\]\([^\)]+\)/g, '$1') // 链接 [text](url)
			text = text.replace(/#{1,6}\s*/g, '') // 标题 # ## ###
			text = text.replace(/^\s*[-*+]\s+/gm, '') // 列表项
			text = text.replace(/^\s*\d+\.\s+/gm, '') // 有序列表
			text = text.replace(/^\s*>\s+/gm, '') // 引用
			text = text.replace(/---+/g, '') // 分割线
			
			// 去除多余的空白字符
			text = text.replace(/\s+/g, ' ').trim()
			
			// 限制显示长度
			if (text.length > 100) {
				text = text.substring(0, 100) + '...'
			}
			
			return text
		},

		// 查看活动详情
		viewActivityDetail(activity) {
			this.currentDetailActivity = activity
			this.showDetailModal = true
		},

		// 关闭详情弹窗
		closeDetailModal() {
			this.showDetailModal = false
			this.currentDetailActivity = null
		},

		// 加载活动列表
		async loadActivities() {
			try {
				const { result } = await uniCloud.callFunction({
					name: 'getCommunityContent',
					data: {
						type: 'activity',
						page: 1,
						pageSize: 50
					}
				})
				
				if (result && result.code === 200 && result.data && result.data.length > 0) {
					// 使用真实数据，确保每个活动都有必要的字段
					this.activityList = result.data.map(activity => ({
						...activity,
						publisher_name: activity.publisher_name || activity.user_name || '未知用户',
						pinned: activity.pinned || false,
						// 确保保留publisher对象
						publisher: activity.publisher || {
							nickname: activity.publisher_name || activity.user_name || '未知用户',
							avatar: activity.publisher_avatar || ''
						}
					}))
					
					// 保存所有数据到allActivityList用于搜索
					this.allActivityList = [...this.activityList]
					
					// 应用当前筛选和搜索条件
					this.applyFilters()
					
					console.log('加载真实活动数据成功:', this.activityList)
					uni.showToast({ title: '加载数据成功', icon: 'success' })
				} else {
					throw new Error('无数据返回')
				}
			} catch (error) {
				console.error('加载活动列表失败:', error)
				// 云函数失败时使用模拟数据作为后备
				this.activityList = [
					{
						_id: '1',
						title: '校园歌唱比赛',
						content: '欢迎参加校园歌唱比赛，展示你的音乐才华！',
						activity_time: Date.now(),
						location: '学校礼堂',
						max_attendees: 100,
						attendee_count: 25,
						status: 'published',
						category: '文体活动',
						pinned: false,
						publisher_name: '学生会文艺部',
						user_id: 'admin1',
						publisher: {
							nickname: '学生会文艺部',
							avatar: ''
						}
					},
					{
						_id: '2', 
						title: '春季运动会',
						content: '一年一度的春季运动会即将开始',
						activity_time: Date.now() + 86400000,
						location: '操场',
						max_attendees: 200,
						attendee_count: 80,
						status: 'reviewed_approved',
						category: '文体活动',
						pinned: true,
						publisher_name: '体育部',
						user_id: 'admin2',
						publisher: {
							nickname: '体育部',
							avatar: ''
						}
					},
					{
						_id: '3',
						title: '"心手相牵·益路同行"校园公益文化节活动',
						content: '活动理念：以公益为纽带，搭建"实践育人"平台，通过多元化公益活动，培养学生社会责任感，传递温暖与善意，让公益精神在校园内外生根发芽。活动内容介绍：一、公益项目市集：创意公益齐亮相；公益岗位招募：邀请校内社团、班级团队以及校外公益组织现场展示特色公益项目；旧物焕新计划：设置旧书、旧玩具置换区，鼓励学生用闲置物品换取积分或参与公益活动。',
						activity_time: new Date('2025-06-17 20:00').getTime(),
						location: '养老院',
						max_attendees: 99,
						attendee_count: 10,
						status: 'pending_review',
						category: '志愿服务',
						pinned: false,
						publisher_name: '志愿者协会',
						user_id: 'user123',
						publisher: {
							nickname: '志愿者协会',
							avatar: ''
						}
					},
					{
						_id: '4',
						title: '计算机科学前沿技术讲座',
						content: '邀请知名教授分享人工智能和机器学习的最新发展',
						activity_time: Date.now() + 172800000,
						location: '学术报告厅',
						max_attendees: 150,
						attendee_count: 45,
						status: 'reviewed_rejected',
						category: '学术讲座',
						pinned: false,
						publisher_name: '计算机学院',
						user_id: 'admin3',
						publisher: {
							nickname: '计算机学院',
							avatar: ''
						}
					}
				]
				
				// 保存所有数据到allActivityList用于搜索
				this.allActivityList = [...this.activityList]
				
				// 应用当前筛选和搜索条件
				this.applyFilters()
				
				console.log('使用模拟活动数据:', this.activityList)
				uni.showToast({ title: '云函数失败，使用模拟数据', icon: 'none' })
			}
		},

		// 创建官方活动
		createOfficialActivity() {
			this.showCreateModal = true
		},

		// 关闭创建活动弹窗
		closeCreateModal() {
			this.showCreateModal = false
			this.resetNewActivity()
		},

		// 重置新活动表单
		resetNewActivity() {
			this.newActivity = {
				title: '',
				category: '',
				activity_time: '',
				location: '',
				max_attendees: '',
				content: '',
				cover_image: '',
				author_name: '官方',
				author_avatar: '',
				selectedDate: '',
				selectedTime: ''
			}
		},

		// 新活动类型选择
		onNewActivityCategoryChange(e) {
			const index = Number(e.detail.value)
			this.newActivity.category = this.categoryOptions.slice(1)[index]
		},

		// 活动日期选择
		onActivityDateChange(e) {
			this.newActivity.selectedDate = e.detail.value
			this.updateActivityTime()
		},
		
		// 活动时间选择
		onActivityTimeChange(e) {
			this.newActivity.selectedTime = e.detail.value
			this.updateActivityTime()
		},
		
		// 更新活动时间戳
		updateActivityTime() {
			if (this.newActivity.selectedDate && this.newActivity.selectedTime) {
				const dateTimeStr = `${this.newActivity.selectedDate} ${this.newActivity.selectedTime}`
				this.newActivity.activity_time = new Date(dateTimeStr).getTime()
			}
		},
		
		// 选择封面图片
		chooseCoverImage() {
			uni.chooseImage({
				count: 1,
				sizeType: ['compressed'],
				sourceType: ['album', 'camera'],
				success: (res) => {
					const tempFilePath = res.tempFilePaths[0]
					this.uploadCoverImage(tempFilePath, 'new')
				},
				fail: (err) => {
					console.error('选择图片失败:', err)
					uni.showToast({
						title: '选择图片失败',
						icon: 'none'
					})
				}
			})
		},
		
		// 删除封面图片
		removeCoverImage() {
			this.newActivity.cover_image = ''
			uni.showToast({
				title: '已删除封面图片',
				icon: 'success'
			})
		},
		
		// 选择编辑封面图片
		chooseEditCoverImage() {
			uni.chooseImage({
				count: 1,
				sizeType: ['compressed'],
				sourceType: ['album', 'camera'],
				success: (res) => {
					const tempFilePath = res.tempFilePaths[0]
					this.uploadCoverImage(tempFilePath, 'edit')
				},
				fail: (err) => {
					console.error('选择图片失败:', err)
					uni.showToast({
						title: '选择图片失败',
						icon: 'none'
					})
				}
			})
		},
		
		// 删除编辑封面图片
		removeEditCoverImage() {
			this.editForm.cover_image = ''
			uni.showToast({
				title: '已删除封面图片',
				icon: 'success'
			})
		},
		
		// 上传封面图片
		async uploadCoverImage(tempFilePath, type) {
			uni.showLoading({ title: '上传中...' })
			
			try {
				// 这里应该调用云存储上传图片
				// 暂时使用本地路径作为模拟
				const uploadResult = await this.uploadImageToCloud(tempFilePath)
				
				if (type === 'new') {
					this.newActivity.cover_image = uploadResult.url || tempFilePath
				} else if (type === 'edit') {
					this.editForm.cover_image = uploadResult.url || tempFilePath
				}
				
				uni.hideLoading()
				uni.showToast({
					title: '上传成功',
					icon: 'success'
				})
			} catch (error) {
				uni.hideLoading()
				console.error('上传图片失败:', error)
				
				// 上传失败时，仍然使用本地路径作为预览
				if (type === 'new') {
					this.newActivity.cover_image = tempFilePath
				} else if (type === 'edit') {
					this.editForm.cover_image = tempFilePath
				}
				
				uni.showToast({
					title: '上传失败，使用本地预览',
					icon: 'none'
				})
			}
		},
		
		// 上传图片到云存储（模拟实现）
		async uploadImageToCloud(filePath) {
			// 这里应该实现真实的云存储上传逻辑
			// 暂时返回模拟结果
			return new Promise((resolve, reject) => {
				setTimeout(() => {
					// 模拟上传成功
					resolve({
						url: filePath, // 实际应该是云存储的URL
						fileID: 'cloud_file_' + Date.now()
					})
				}, 2000)
			})
		},

		// 创建活动
		async createActivity() {
			// 表单验证
			if (!this.newActivity.title.trim()) {
				uni.showToast({ title: '请输入活动标题', icon: 'none' })
				return
			}
			if (!this.newActivity.category) {
				uni.showToast({ title: '请选择活动类型', icon: 'none' })
				return
			}
			if (!this.newActivity.activity_time) {
				uni.showToast({ title: '请选择活动时间', icon: 'none' })
				return
			}
			if (!this.newActivity.location.trim()) {
				uni.showToast({ title: '请输入活动地点', icon: 'none' })
				return
			}
			if (!this.newActivity.max_attendees || this.newActivity.max_attendees <= 0) {
				uni.showToast({ title: '请输入有效的最大参与人数', icon: 'none' })
				return
			}
			if (!this.newActivity.content.trim()) {
				uni.showToast({ title: '请输入活动描述', icon: 'none' })
				return
			}
			if (!this.newActivity.author_name.trim()) {
				uni.showToast({ title: '请输入活动作者', icon: 'none' })
				return
			}

			// 显示加载提示
			uni.showLoading({ title: '创建中...' })

			try {
				console.log('准备创建活动，数据:', this.newActivity)
				
				const { result } = await uniCloud.callFunction({
					name: 'createActivity',
					data: {
						title: this.newActivity.title,
						category: this.newActivity.category,
						content: this.newActivity.content,
						activity_time: this.newActivity.activity_time,
						location: this.newActivity.location,
						max_attendees: parseInt(this.newActivity.max_attendees),
						cover_image: this.newActivity.cover_image,
						author_name: this.newActivity.author_name,
						author_avatar: this.newActivity.author_avatar,
						publisher_name: this.newActivity.author_name,
						status: 'published', // 官方活动直接发布
						pinned: false,
						attendee_count: 0
					}
				})
				
				uni.hideLoading()
				
				console.log('云函数返回结果:', result)
				
				if (result && result.code === 200) {
					uni.showToast({ 
						title: '活动创建成功', 
						icon: 'success',
						duration: 2000
					})
					this.closeCreateModal()
					// 延迟重新加载，确保数据已保存
					setTimeout(() => {
						this.loadActivities()
					}, 1000)
				} else {
					throw new Error(result?.msg || '创建失败')
				}
			} catch (error) {
				uni.hideLoading()
				console.error('创建活动失败:', error)
				
				// 显示具体错误信息
				const errorMsg = error.message || '创建失败，请重试'
				uni.showToast({ 
					title: errorMsg, 
					icon: 'none',
					duration: 3000
				})
				
				// 如果是网络错误，提供模拟创建作为备选
				if (errorMsg.includes('网络') || errorMsg.includes('超时')) {
					const newActivityData = {
						_id: 'temp_' + Date.now(),
						content_type: 'activity',
						title: this.newActivity.title,
						category: this.newActivity.category,
						content: this.newActivity.content,
						activity_time: this.newActivity.activity_time,
						location: this.newActivity.location,
						max_attendees: parseInt(this.newActivity.max_attendees),
						attendee_count: 0,
						publisher_name: '官方',
						status: 'published',
						pinned: false,
						like_count: 0,
						comment_count: 0,
						create_time: Date.now(),
						publisher: {
							nickname: '官方',
							avatar: ''
						},
						user_info: {
							nickname: '官方',
							username: 'official',
							avatar: ''
						}
					}
					
					this.allActivityList.unshift(newActivityData)
					this.applyFilters()
					
					uni.showToast({ 
						title: '活动已创建（本地缓存）', 
						icon: 'success',
						duration: 2000
					})
					this.closeCreateModal()
				}
			}
		},

		// 类型筛选
		onCategoryChange(e) {
			const index = Number(e.detail.value)
			this.filters.category = this.categoryOptions[index]
			this.applyFilters()
		},

		// 状态筛选
		onStatusChange(e) {
			const index = Number(e.detail.value)
			this.filters.status = this.statusOptions[index]
			this.applyFilters()
		},

		// 搜索输入事件（实时搜索）
		onSearchInput(e) {
			// 清除之前的定时器
			if (this.searchTimer) {
				clearTimeout(this.searchTimer)
			}
			
			// 设置防抖，300ms后执行搜索
			this.searchTimer = setTimeout(() => {
				this.applyFilters()
			}, 300)
		},

		// 搜索确认事件
		onSearchConfirm() {
			// 清除定时器，立即执行搜索
			if (this.searchTimer) {
				clearTimeout(this.searchTimer)
			}
			this.applyFilters()
		},

		// 应用筛选和搜索条件
		applyFilters() {
			let filteredList = [...this.allActivityList]

			// 关键词搜索
			if (this.filters.keyword && this.filters.keyword.trim()) {
				const keyword = this.filters.keyword.trim().toLowerCase()
				filteredList = filteredList.filter(activity => {
					const title = (activity.title || '').toLowerCase()
					const content = (activity.content || '').toLowerCase()
					const location = (activity.location || '').toLowerCase()
					const publisherName = (activity.user_info?.nickname || activity.publisher?.nickname || activity.publisher_name || '').toLowerCase()
					
					return title.includes(keyword) || 
						   content.includes(keyword) || 
						   location.includes(keyword) ||
						   publisherName.includes(keyword)
				})
			}

			// 类型筛选
			if (this.filters.category && this.filters.category !== '全部') {
				filteredList = filteredList.filter(activity => activity.category === this.filters.category)
			}

			// 状态筛选
			if (this.filters.status && this.filters.status !== '全部') {
				const statusKey = this.getStatusKey(this.filters.status)
				filteredList = filteredList.filter(activity => activity.status === statusKey)
			}

			// 按优先级排序：待审核 > 已拒绝 > 已发布 > 已通过 > 已隐藏（最底部）
			filteredList.sort((a, b) => {
				const priorityA = this.getActivityPriority(a)
				const priorityB = this.getActivityPriority(b)
				
				// 如果优先级不同，按优先级排序
				if (priorityA !== priorityB) {
					return priorityA - priorityB
				}
				
				// 如果优先级相同，按时间倒序排序（新的在前）
				const timeA = a.activity_time || 0
				const timeB = b.activity_time || 0
				return timeB - timeA
			})

			this.activityList = filteredList
		},

		// 获取活动优先级（用于排序）
		getActivityPriority(activity) {
			const priorityMap = {
				'pending_review': 1,      // 待审核 - 最高优先级
				'reviewed_rejected': 2,   // 已拒绝 - 第二优先级
				'published': 3,           // 已发布 - 第三优先级
				'reviewed_approved': 4,   // 已通过 - 第四优先级
				'hidden': 5,              // 已隐藏 - 最低优先级（显示在最底部）
			}
			return priorityMap[activity.status] || 6
		},

		// 获取状态键名
		getStatusKey(text) {
			const keyMap = {
				'待审核': 'pending_review',
				'已发布': 'published',
				'已审核通过': 'reviewed_approved',
				'已审核拒绝': 'reviewed_rejected',
				'已隐藏': 'hidden',
				'已删除': 'deleted'
			}
			return keyMap[text] || text
		},

		// 获取状态显示文本
		getStatusText(status) {
			const textMap = {
				'pending_review': '待审核',
				'published': '已发布',
				'reviewed_approved': '已审核通过',
				'reviewed_rejected': '已审核拒绝',
				'hidden': '已隐藏',
				'deleted': '已删除'
			}
			return textMap[status] || status
		},

		// 获取可用的审核操作
		getAvailableAuditActions(activity) {
			const actions = []
			
			// 根据当前状态显示不同的审核选项
			if (activity.status === 'pending_review') {
				actions.push(
					{ key: 'reviewed_approved', text: '通过', icon: '✓', type: 'approve' },
					{ key: 'reviewed_rejected', text: '拒绝', icon: '✕', type: 'reject' }
				)
			} else if (activity.status === 'published') {
				actions.push(
					{ key: 'reviewed_approved', text: '通过', icon: '✓', type: 'approve' },
					{ key: 'reviewed_rejected', text: '拒绝', icon: '✕', type: 'reject' }
				)
			} else if (activity.status === 'reviewed_rejected' || activity.status === 'hidden') {
				actions.push(
					{ key: 'reviewed_approved', text: '通过', icon: '✓', type: 'approve' },
					{ key: 'published', text: '恢复', icon: '↻', type: 'approve' }
				)
			} else if (activity.status === 'reviewed_approved') {
				actions.push(
					{ key: 'pending_review', text: '重审', icon: '⚠', type: 'warn' }
				)
			}
			
			return actions
		},

		// 活动审核
		async auditActivity(activity, action) {
					let reason = ''
					
			if (['reviewed_rejected', 'hidden', 'pending_review'].includes(action)) {
				const actionText = action === 'reviewed_rejected' ? '拒绝' : 
								 action === 'hidden' ? '隐藏' : '重审'
				const reasonResult = await this.promptReason(`请输入${actionText}理由`)
						if (!reasonResult) return
						reason = reasonResult
					}
					
					try {
						const { result } = await uniCloud.callFunction({
							name: 'auditContent',
							data: {
								contentId: activity._id,
								type: 'activity',
								action: action,
								reason: reason
							}
						})
						if (result && result.code === 200) {
					uni.showToast({ title: '操作成功', icon: 'success' })
							this.loadActivities()
						}
					} catch (error) {
				// 模拟成功更新本地状态
				const index = this.activityList.findIndex(a => a._id === activity._id)
				if (index !== -1) {
					this.activityList[index].status = action
					this.allActivityList[index].status = action
				}
				uni.showToast({ title: '操作成功', icon: 'success' })
			}
		},

		// 编辑活动
		editActivity(activity) {
			this.currentEditActivity = activity
			this.editForm = {
				title: activity.title || '',
				category: activity.category || '',
				activity_time: activity.activity_time || '',
				location: activity.location || '',
				max_attendees: activity.max_attendees || '',
				content: activity.content || '',
				cover_image: activity.cover_image || '',
				author_name: activity.author_name || activity.publisher_name || '官方',
				author_avatar: activity.author_avatar || '',
				selectedDate: activity.activity_time ? this.getDateValue(activity.activity_time) : '',
				selectedTime: activity.activity_time ? this.getTimeValue(activity.activity_time) : ''
			}
			this.showEditModal = true
		},

		// 隐藏活动
		async hideActivity(activity) {
			const confirmed = await this.confirm('确定要隐藏这个活动吗？隐藏后活动将不再对用户显示。')
			if (!confirmed) return
			
			const reason = await this.promptReason('请输入隐藏理由')
			if (!reason) return
			
			try {
				const { result } = await uniCloud.callFunction({
					name: 'auditContent',
					data: {
						contentId: activity._id,
						type: 'activity',
						action: 'hidden',
						reason: reason
					}
				})
				
				if (result && result.code === 200) {
					uni.showToast({ title: '隐藏成功', icon: 'success' })
					this.loadActivities()
				} else {
					throw new Error(result.msg || '隐藏失败')
				}
			} catch (error) {
				console.error('隐藏活动失败:', error)
				// 模拟成功，更新本地状态
				const index = this.allActivityList.findIndex(a => a._id === activity._id)
				if (index !== -1) {
					this.allActivityList[index].status = 'hidden'
				}
				this.applyFilters()
				uni.showToast({ title: '隐藏成功', icon: 'success' })
			}
		},

		// 下架活动
		async takeDownActivity(activity) {
			const confirmed = await this.confirm('确定要下架这个活动吗？')
			if (!confirmed) return
			
			try {
				// 这里应该调用下架活动的云函数
				uni.showToast({ title: '下架成功', icon: 'success' })
				this.loadActivities()
			} catch (error) {
				uni.showToast({ title: '下架成功', icon: 'success' })
			}
		},


		// 删除活动
		async deleteActivity(activity) {
			const confirmed = await this.confirm('确定要删除这个活动吗？')
			if (!confirmed) return
			
			try {
				const { result } = await uniCloud.callFunction({
					name: 'deleteContent',
					data: {
						contentId: activity._id,
						type: 'activity'
					}
				})
				if (result && result.code === 200) {
					uni.showToast({ title: '已删除', icon: 'success' })
					this.loadActivities()
				}
			} catch (error) {
				const index = this.activityList.findIndex(a => a._id === activity._id)
				if (index !== -1) {
					this.activityList.splice(index, 1)
				}
				uni.showToast({ title: '已删除', icon: 'success' })
			}
		},

		// 提示输入理由
		promptReason(title) {
			return new Promise((resolve) => {
				uni.showModal({
					title: title,
					editable: true,
					placeholderText: '请输入理由...',
					success: (res) => {
						resolve(res.confirm && res.content ? res.content : null)
					}
				})
			})
		},

		// 确认对话框
		confirm(message) {
			return new Promise((resolve) => {
				uni.showModal({
					title: '确认',
					content: message,
					success: (res) => resolve(res.confirm)
				})
			})
		},

		// 关闭编辑活动弹窗
		closeEditModal() {
			this.showEditModal = false
			this.currentEditActivity = null
			this.resetEditForm()
		},

		// 重置编辑表单
		resetEditForm() {
			this.editForm = {
				title: '',
				category: '',
				activity_time: '',
				location: '',
				max_attendees: '',
				content: '',
				cover_image: '',
				author_name: '官方',
				author_avatar: '',
				selectedDate: '',
				selectedTime: ''
			}
		},

		// 编辑表单活动类型选择
		onEditActivityCategoryChange(e) {
			const index = Number(e.detail.value)
			this.editForm.category = this.categoryOptions.slice(1)[index]
		},

		// 编辑表单活动日期选择
		onEditActivityDateChange(e) {
			this.editForm.selectedDate = e.detail.value
			this.updateEditActivityTime()
		},
		
		// 编辑表单活动时间选择
		onEditActivityTimeChange(e) {
			this.editForm.selectedTime = e.detail.value
			this.updateEditActivityTime()
		},
		
		// 更新编辑表单活动时间戳
		updateEditActivityTime() {
			if (this.editForm.selectedDate && this.editForm.selectedTime) {
				const dateTimeStr = `${this.editForm.selectedDate} ${this.editForm.selectedTime}`
				this.editForm.activity_time = new Date(dateTimeStr).getTime()
			}
		},

		// 保存活动编辑
		async saveActivityEdit() {
			// 表单验证
			if (!this.editForm.title.trim()) {
				uni.showToast({ title: '请输入活动标题', icon: 'none' })
				return
			}
			if (!this.editForm.category) {
				uni.showToast({ title: '请选择活动类型', icon: 'none' })
				return
			}
			if (!this.editForm.activity_time) {
				uni.showToast({ title: '请选择活动时间', icon: 'none' })
				return
			}
			if (!this.editForm.location.trim()) {
				uni.showToast({ title: '请输入活动地点', icon: 'none' })
				return
			}
			if (!this.editForm.max_attendees || this.editForm.max_attendees <= 0) {
				uni.showToast({ title: '请输入有效的最大参与人数', icon: 'none' })
				return
			}
			if (!this.editForm.content.trim()) {
				uni.showToast({ title: '请输入活动描述', icon: 'none' })
				return
			}

			try {
				const { result } = await uniCloud.callFunction({
					name: 'update-content',
					data: {
						contentId: this.currentEditActivity._id,
						type: 'activity',
						title: this.editForm.title,
						content: this.editForm.content,
						category: this.editForm.category,
						activity_time: this.editForm.activity_time,
						location: this.editForm.location,
						max_attendees: Number(this.editForm.max_attendees)
					}
				})
				
				if (result && result.code === 200) {
					uni.showToast({ title: '保存成功', icon: 'success' })
					this.closeEditModal()
					this.loadActivities() // 重新加载活动列表
				} else {
					throw new Error(result.msg || '保存失败')
				}
			} catch (error) {
				console.error('保存编辑失败:', error)
				// 模拟成功，更新本地数据
				const index = this.activityList.findIndex(a => a._id === this.currentEditActivity._id)
				if (index !== -1) {
					this.activityList[index].title = this.editForm.title
					this.activityList[index].content = this.editForm.content
					this.activityList[index].category = this.editForm.category
					this.activityList[index].activity_time = this.editForm.activity_time
					this.activityList[index].location = this.editForm.location
					this.activityList[index].max_attendees = Number(this.editForm.max_attendees)
				}
				
				// 同时更新 allActivityList
				const allIndex = this.allActivityList.findIndex(a => a._id === this.currentEditActivity._id)
				if (allIndex !== -1) {
					this.allActivityList[allIndex].title = this.editForm.title
					this.allActivityList[allIndex].content = this.editForm.content
					this.allActivityList[allIndex].category = this.editForm.category
					this.allActivityList[allIndex].activity_time = this.editForm.activity_time
					this.allActivityList[allIndex].location = this.editForm.location
					this.allActivityList[allIndex].max_attendees = Number(this.editForm.max_attendees)
				}
				
				uni.showToast({ title: '保存成功', icon: 'success' })
				this.closeEditModal()
			}
		}
	}
}
</script>

<style scoped>
/* 引入本地阿里图标库 */
@import url('/static/fonts/iconfont.css');

/* 图标样式配置 */
.iconfont {
	font-size: 24rpx;
	line-height: 1;
	display: inline-block;
}

.page {
	padding: 20rpx;
	height: 100vh;
	display: flex;
	flex-direction: column;
}

.section-header {
	margin-bottom: 30rpx;
}

.section-title {
	font-size: 36rpx;
	font-weight: 600;
	color: #333;
	display: block;
	margin-bottom: 8rpx;
}

.section-desc {
	font-size: 26rpx;
	color: #666;
	display: block;
}

.create-btn {
	padding: 16rpx 24rpx;
	background: #1677ff;
	color: #fff;
	border-radius: 8rpx;
	font-size: 26rpx;
	border: none;
	white-space: nowrap;
	transition: all 0.3s;
}

.create-btn:hover {
	background: #0958d9;
}

/* 筛选工具栏 */
.filter-toolbar {
	display: flex;
	align-items: center;
	gap: 16rpx;
	margin-bottom: 20rpx;
	flex-wrap: wrap;
}

.search-input {
	flex: 2;
	min-width: 300rpx;
	max-width: 500rpx;
	background: #fff;
	border-radius: 16rpx;
	padding: 20rpx 24rpx;
	border: 2rpx solid #e0e0e0;
	font-size: 30rpx;
	height: 88rpx;
	box-sizing: border-box;
	transition: all 0.3s;
}

.search-input:focus {
	border-color: #007aff;
	box-shadow: 0 0 0 4rpx rgba(0, 122, 255, 0.1);
}

.picker-btn {
	padding: 16rpx 20rpx;
	background: #fff;
	border-radius: 12rpx;
	border: 2rpx solid #f0f0f0;
	font-size: 26rpx;
	color: #333;
	white-space: nowrap;
}

.filter-btn {
	padding: 16rpx 24rpx;
	background: #1677ff;
	color: #fff;
	border-radius: 8rpx;
	font-size: 26rpx;
	border: none;
	transition: all 0.3s;
}

.filter-btn:hover {
	background: #0958d9;
}

.content-list {
	flex: 1;
	overflow-y: auto;
}

.content-item {
	background: #fff;
	border-radius: 16rpx;
	padding: 24rpx;
	margin-bottom: 16rpx;
	box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
	border: 2rpx solid transparent;
	transition: all 0.3s;
}

.content-item:hover {
	box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.12);
}

.content-item.pending {
	border-color: #ffd700;
	background: linear-gradient(135deg, #fff9e6 0%, #fff 100%);
}

.content-item.approved {
	border-color: #52c41a;
	background: linear-gradient(135deg, #f6ffed 0%, #fff 100%);
}

.content-item.rejected {
	border-color: #ff4d4f;
	background: linear-gradient(135deg, #fff2f0 0%, #fff 100%);
}

/* 活动项目样式 */
.content-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 16rpx;
}

.content-meta {
	display: flex;
	align-items: center;
	gap: 12rpx;
	flex-wrap: wrap;
}

.attendee-info {
	font-size: 22rpx;
	color: #8c8c8c;
	font-weight: 500;
}

.publish-time {
	font-size: 24rpx;
	color: #999;
}

.content-main {
	margin-bottom: 16rpx;
}

.content-title {
	font-size: 32rpx;
	font-weight: 600;
	color: #333;
	display: block;
	margin-bottom: 8rpx;
	line-height: 1.4;
}

.activity-info {
	font-size: 24rpx;
	color: #8c8c8c;
	margin-top: 8rpx;
	display: flex;
	gap: 20rpx;
	flex-wrap: wrap;
}

.content-category {
	padding: 4rpx 12rpx;
	background: #f0f8ff;
	color: #1677ff;
	border-radius: 6rpx;
	font-size: 22rpx;
	font-weight: 500;
	white-space: nowrap;
}

.content-status {
	padding: 4rpx 12rpx;
	border-radius: 8rpx;
	font-size: 22rpx;
	font-weight: 600;
	white-space: nowrap;
}

/* 不同状态的样式 */
.content-status.pending_review {
	background: #fffbe6;
	color: #ad8b00;
}

.content-status.published {
	background: #f6ffed;
	color: #389e0d;
}

.content-status.reviewed_approved {
	background: #e6f7ff;
	color: #1677ff;
}

.content-status.reviewed_rejected {
	background: #fff2f0;
	color: #cf1322;
}

.content-status.hidden {
	background: #f5f5f5;
	color: #8c8c8c;
}

.content-status.deleted {
	background: #262626;
	color: #fff;
}

.content-text {
	font-size: 26rpx;
	color: #595959;
	line-height: 1.5;
	margin: 12rpx 0;
	max-height: 120rpx;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
}

.content-meta {
	display: flex;
	align-items: center;
	gap: 20rpx;
	font-size: 24rpx;
	color: #888;
	margin-bottom: 16rpx;
	flex-wrap: wrap;
}

.content-actions {
	display: flex;
	gap: 8rpx;
	justify-content: flex-end;
	align-items: center;
	flex-wrap: nowrap;
	margin-top: 16rpx;
	padding-top: 16rpx;
	border-top: 1rpx solid #f0f0f0;
	overflow-x: auto;
	min-height: 60rpx;
}

/* 新的按钮样式 - 简约卡片式 */
.action-btn {
	display: flex;
	align-items: center; 
	justify-content: center;
	gap: 8rpx;
	padding: 14rpx 20rpx;
	border-radius: 10rpx;
	border: none;
	font-size: 26rpx;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
	min-width: 150rpx;
	height: 60rpx;
	line-height: 60rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
	flex: 1;
	max-width: 180rpx;
	white-space: nowrap;
	overflow: hidden;
}


.action-btn:hover {
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.12);
}

.action-btn:active {
	transform: translateY(0);
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}

/* 查看详情按钮 */
.detail-btn {
	background: #1677ff;
	color: #fff;
}

.detail-btn:hover {
	background: #0958d9;
}

/* 编辑按钮 */
.edit-btn {
	background: #fafafa;
	color: #595959;
	border: 1rpx solid #d9d9d9;
}

.edit-btn:hover {
	background: #f0f0f0;
	color: #262626;
	border-color: #b7b7b7;
}

/* 隐藏按钮 */
.hide-btn {
	background: #fafafa;
	color: #595959;
	border: 1rpx solid #d9d9d9;
}

.hide-btn:hover {
	background: #f0f0f0;
	color: #262626;
	border-color: #b7b7b7;
}

/* 下架按钮 */
.down-btn {
	background: #fafafa;
	color: #595959;
	border: 1rpx solid #d9d9d9;
}

.down-btn:hover {
	background: #f0f0f0;
	color: #262626;
	border-color: #b7b7b7;
}

/* 删除按钮 */
.delete-btn {
	background: #ff4d4f;
	color: #fff;
}

.delete-btn:hover {
	background: #cf1322;
}

/* 创建活动弹窗样式 */
.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 100;
}

/* 审核弹窗有更高的层级 */
.modal-overlay:has(.audit-modal) {
	z-index: 1000;
}

.modal-content {
	background: #fff;
	border-radius: 16rpx;
	width: 90%;
	max-width: 600rpx;
	max-height: 80vh;
	display: flex;
	flex-direction: column;
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 24rpx;
	border-bottom: 2rpx solid #f0f0f0;
}

.modal-title {
	font-size: 32rpx;
	font-weight: 600;
	color: #333;
}

.modal-close {
	font-size: 48rpx;
	color: #999;
	cursor: pointer;
	line-height: 1;
}

.modal-body {
	flex: 1;
	padding: 24rpx;
	overflow-y: auto;
}

.form-group {
	margin-bottom: 24rpx;
}

.form-label {
	display: block;
	font-size: 28rpx;
	color: #333;
	margin-bottom: 8rpx;
	font-weight: 500;
}

.form-input, .form-picker {
	width: 100%;
	padding: 20rpx 16rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 8rpx;
	font-size: 28rpx;
	box-sizing: border-box;
	background: #fff;
	min-height: 88rpx;
}

.form-input:focus {
	border-color: #007aff;
	outline: none;
}

.form-picker {
	color: #333;
	cursor: pointer;
	display: flex;
	align-items: center;
	min-height: 48rpx;
	position: relative;
}

.form-picker::after {
	content: '▼';
	position: absolute;
	right: 16rpx;
	color: #999;
	font-size: 24rpx;
}

.picker-wrapper {
	position: relative;
	z-index: 200;
}

/* 日期时间选择器组样式 */
.datetime-picker-group {
	display: flex;
	gap: 16rpx;
}

.date-picker {
	flex: 1;
}

.time-picker {
	flex: 1;
}

/* 封面上传样式 */
.cover-upload-container {
	margin-top: 8rpx;
}

.cover-upload {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 200rpx;
	border: 2rpx dashed #d9d9d9;
	border-radius: 8rpx;
	background: #fafafa;
	cursor: pointer;
	transition: all 0.3s ease;
}

.cover-upload:hover {
	border-color: #1677ff;
	background: #f0f8ff;
}

.upload-icon {
	font-size: 48rpx;
	color: #8c8c8c;
	margin-bottom: 8rpx;
}

.upload-text {
	font-size: 28rpx;
	color: #595959;
	margin-bottom: 4rpx;
}

.upload-tip {
	font-size: 22rpx;
	color: #8c8c8c;
}

.cover-preview {
	position: relative;
	border-radius: 8rpx;
	overflow: hidden;
}

.cover-image {
	width: 100%;
	height: 200rpx;
	border-radius: 8rpx;
	display: block;
}

.cover-actions {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16rpx;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.cover-preview:hover .cover-actions {
	opacity: 1;
}

.cover-btn {
	padding: 8rpx 16rpx;
	border-radius: 6rpx;
	font-size: 24rpx;
	border: none;
	cursor: pointer;
	transition: all 0.3s ease;
}

.change-btn {
	background: #1677ff;
	color: #fff;
}

.change-btn:hover {
	background: #0958d9;
}

.remove-btn {
	background: #ff4d4f;
	color: #fff;
}

.remove-btn:hover {
	background: #cf1322;
}

.form-textarea {
	width: 100%;
	padding: 20rpx 16rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 8rpx;
	font-size: 28rpx;
	box-sizing: border-box;
	background: #fff;
	min-height: 160rpx;
	resize: vertical;
}

.form-textarea:focus {
	border-color: #007aff;
	outline: none;
}

.modal-footer {
	display: flex;
	gap: 16rpx;
	padding: 24rpx;
	border-top: 2rpx solid #f0f0f0;
}

.modal-btn {
	flex: 1;
	padding: 16rpx 24rpx;
	border-radius: 8rpx;
	font-size: 28rpx;
	border: none;
	cursor: pointer;
}

.cancel-btn {
	background: #f5f5f5;
	color: #666;
}

.cancel-btn:hover {
	background: #e8e8e8;
}

.confirm-btn {
	background: #1677ff;
	color: #fff;
}

.confirm-btn:hover {
	background: #0958d9;
}

/* 响应式适配 */
@media (max-width: 750rpx) {
	.filter-toolbar {
		flex-direction: column;
		align-items: stretch;
		gap: 12rpx;
	}
	
	.search-input {
		order: 1;
	}
	
	.picker-btn {
		flex: 1;
		text-align: center;
	}
	
	.filter-btn, .create-btn {
		order: 2;
		margin-top: 8rpx;
	}
	
	.content-actions {
		justify-content: flex-start;
		gap: 6rpx;
		overflow-x: auto;
		flex-wrap: nowrap;
	}
	
	.action-btn {
		min-width: 120rpx;
		max-width: 160rpx;
		padding: 12rpx 16rpx;
		font-size: 24rpx;
		height: 48rpx;
		flex-shrink: 0;
	}
	
	.iconfont {
		font-size: 22rpx;
	}
	
	.content-meta {
		flex-direction: column;
		align-items: flex-start;
		gap: 8rpx;
	}
	
	.content-header-item {
		flex-wrap: wrap;
		gap: 8rpx;
	}
	
	.modal-content {
		width: 95%;
		max-height: 85vh;
	}
	
	.modal-footer {
		flex-direction: column;
	}
}

/* 审核按钮组样式 */
.audit-actions {
	display: flex;
	gap: 8rpx;
	margin-right: 8rpx;
}

.audit-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8rpx;
	padding: 14rpx 20rpx;
	border-radius: 10rpx;
	border: none;
	font-size: 26rpx;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
	height: 60rpx;
	min-width: 150rpx;
	line-height: 60rpx;
}

.audit-btn.approve {
	background: #52c41a;
	color: #fff;
}

.audit-btn.approve:hover {
	background: #389e0d;
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 16rpx rgba(82, 196, 26, 0.25);
}

.audit-btn.reject {
	background: #ff4d4f;
	color: #fff;
}

.audit-btn.reject:hover {
	background: #cf1322;
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 16rpx rgba(255, 77, 79, 0.25);
}

.audit-btn.warn {
	background: #faad14;
	color: #fff;
}

.audit-btn.warn:hover {
	background: #d48806;
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 16rpx rgba(250, 173, 20, 0.25);
}

.audit-btn:active {
	transform: translateY(0);
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}

@media (max-width: 750rpx) {
	.audit-actions {
		flex-direction: column;
		gap: 6rpx;
		margin-right: 4rpx;
	}
	
	.audit-btn {
		height: 48rpx;
		padding: 12rpx 16rpx;
		font-size: 24rpx;
		min-width: 120rpx;
		max-width: 160rpx;
		flex-shrink: 0;
	}
}

/* 活动详情弹窗样式 */
.detail-modal {
	background: #fff;
	border-radius: 20rpx;
	width: 90%;
	max-width: 700rpx;
	max-height: 80vh;
	box-shadow: 0 10rpx 40rpx rgba(0, 0, 0, 0.2);
	overflow: hidden;
	animation: detailModalSlideIn 0.3s ease-out;
	display: flex;
	flex-direction: column;
}

@keyframes detailModalSlideIn {
	from {
		transform: translateY(-50rpx);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}

.detail-modal .modal-header {
	background: #f8f9fa;
	color: #495057;
	padding: 24rpx 30rpx;
	border-bottom: 1rpx solid #e9ecef;
}

.detail-modal .modal-title {
	font-size: 30rpx;
	font-weight: 500;
	color: #6c757d;
}

.detail-modal .modal-close {
	font-size: 32rpx;
	cursor: pointer;
	line-height: 1;
	color: #adb5bd;
	transition: color 0.3s;
}

.detail-modal .modal-close:hover {
	color: #6c757d;
}

.detail-modal .modal-body {
	flex: 1;
	padding: 0;
	overflow-y: auto;
}

.detail-content {
	padding: 24rpx 30rpx;
}

.detail-section {
	display: flex;
	align-items: flex-start;
	margin-bottom: 20rpx;
	padding-bottom: 16rpx;
	border-bottom: 1rpx solid #f5f5f5;
}

.detail-section.full-width {
	flex-direction: column;
	align-items: stretch;
}

.detail-label {
	font-size: 28rpx;
	font-weight: 600;
	color: #333;
	min-width: 120rpx;
	margin-right: 16rpx;
}

.detail-value {
	font-size: 28rpx;
	color: #666;
	flex: 1;
	line-height: 1.4;
}

.detail-value.status {
	padding: 4rpx 12rpx;
	border-radius: 8rpx;
	font-size: 24rpx;
	font-weight: 600;
	display: inline-block;
}

.detail-value.status.pending_review {
	background: #fff3cd;
	color: #856404;
}

.detail-value.status.published {
	background: #d4edda;
	color: #155724;
}

.detail-value.status.reviewed_approved {
	background: #cce5ff;
	color: #0066cc;
}

.detail-value.status.reviewed_rejected {
	background: #f8d7da;
	color: #721c24;
}

.detail-value.status.hidden {
	background: #f5f5f5;
	color: #6c757d;
}

.detail-description-container {
	max-height: 300rpx;
	margin-top: 12rpx;
	border: 1rpx solid #e9ecef;
	border-radius: 8rpx;
	background: #f8f9fa;
}

.detail-description {
	font-size: 26rpx;
	color: #555;
	line-height: 1.6;
	padding: 16rpx;
	display: block;
	word-wrap: break-word;
	white-space: pre-wrap;
}

.detail-modal .modal-footer {
	padding: 20rpx 30rpx;
	border-top: 1rpx solid #f0f0f0;
	display: flex;
	justify-content: center;
}

.close-btn {
	background: #f8f9fa;
	color: #6c757d;
	border: 1rpx solid #dee2e6;
	padding: 12rpx 32rpx;
	border-radius: 8rpx;
	font-size: 28rpx;
	cursor: pointer;
	transition: all 0.3s;
}

.close-btn:hover {
	background: #e9ecef;
	color: #495057;
}

@media (max-width: 750rpx) {
	.detail-modal {
		width: 95%;
		max-height: 85vh;
	}
	
	.detail-section {
		flex-direction: column;
		align-items: flex-start;
	}
	
	.detail-label {
		margin-bottom: 8rpx;
		margin-right: 0;
	}
}
</style>
